home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / pascal / fastdir.zip / FASTDIR.DOC next >
Text File  |  1993-06-15  |  4KB  |  118 lines

  1.  
  2. WHAT IT DOES
  3. ------------
  4.  
  5. FASTDIR is a  PASCAL program that will search directory  paths and return a
  6. linked list  of all files that  match the search critera.  Additionally, it
  7. can  handle ARJ,ZIP,LZH,ARC  and PAK  archive  files  as if  they too  were
  8. directories on your disk.
  9.  
  10. The search MASK can contain  wildcards and multiple extensions. Each record
  11. in the list is made up as follows :
  12.  
  13.   DirPtr    = ^DirRec;
  14.  
  15.   DirRec   = RECORD
  16.                fType  : FILETYPES;    { see filetypes }
  17.                Attr   : WORD;         { DOS file Attribute }
  18.                Time   : LONGINT;      { DOS file date/time }
  19.                PSize,                 { packed size if in archive }
  20.                Size   : LONGINT;      { orig size or DOS file size }
  21.                Method,                { archive method if in archive }
  22.                Name   : STRING [12];  { file name }
  23.                Path   : PathStr;      { file path }
  24.                Tag    : BOOLEAN;      { marked ??? }
  25.                Next,                  { next file  }
  26.                Prev   : DirPtr;       { prev file  }
  27.              END;
  28. We then  create a structured  RECORD or list  containing any number  (up to
  29. MAXDIRSIZE) of  DirRec. Each of our  DirRec's is pointed to  by a DirPtr as
  30. they are  added to the  HEAP. Each record  takes approximatly 113  Bytes of
  31. memory.
  32.  
  33.  
  34.   DirList  = RECORD
  35.              Root,
  36.              Last,
  37.              Current  : DirPtr;         { Points to Root,Last,Current items }
  38.              Path     : PathStr;        { Dir Path Or Archive Name }
  39.              Mask     : PathStr;        { Command Line or params }
  40.              ArcType  : FILETYPES;      { DIR or Type of Archive }
  41.              Recurse  : BOOLEAN;        { Include SUBS Too }
  42.              Count,                     { file in this list }
  43.              Tagged   : INTEGER;        { tagged count }
  44.              Space,                     { space used by all files }
  45.              TSpace   : LONGINT;        { space used by tagged files }
  46.              Less     : LessFunc;       { Sort function }
  47.              END;
  48.  
  49.  
  50. To create and use a list, we would declare a VAR in our program :
  51.  
  52. VAR
  53.      Sample : DirList;
  54.  
  55. Technically, we could  have several lists at once,  memory permitting. Each
  56. one would have its own path, mask and could be handled independently.
  57.  
  58.  
  59. HOW IT WORKS
  60. ------------
  61.  
  62. The process  of searching a  disk is really  very simple. Essentially,  the
  63. process goes like this :
  64.  
  65. 1. Declare a VAR for our list.
  66.  
  67.                         VAR
  68.                             Sample : DirList;
  69.  
  70.  
  71. 2. Initialize our List. This is  ABSOLUTELY necessary as we MUST initialize
  72. the NEXT/PREV pointers to NIL.
  73.  
  74.                         InitializeDir(Sample);
  75.  
  76. 3. Set the PATH, MASK and RECURSE values.
  77.  
  78.                         Sample.Path := FExpand('\');
  79.  
  80.                         Sample.Mask := '*.ZIP *.ARJ';
  81.                                 { multiple extensions OK !!    }
  82.  
  83.                         Sample.Recurse := TRUE;
  84.  
  85. 4. Find all files matching.
  86.  
  87.                         FindFiles(Sample,Sample.Path);
  88.  
  89.                         OR
  90.  
  91.                         GetFiles(Sample,AnyArcOrDirName,Mask,SortFormat);
  92.  
  93.    Here,  GETFILES will  decide whether  ANYARCORDIRNAME is  a Directory OR
  94.    Archive and return all of the  file members in SAMPLE. SortFormat is any
  95.    one of the SORT functions avaiable. See FASTDIR.PAS for these.
  96.  
  97. 5. Traverse our list and do something with the files.
  98.  
  99.                   Sample.Current := Sample.Root;
  100.                   WHILE Sample.Current <> NIL DO
  101.                         BEGIN
  102.                         { Call any procedure that you want to do something }
  103.                         HandleTheFile(Sample.Current);
  104.                         Sample.Current := Sample.Current^.Next;
  105.                         END;
  106.  
  107.  
  108.  
  109. 6.  Clean up and dispose of memory used.
  110.  
  111.                         DestroyDirList(Sample);
  112.  
  113.  
  114. That is all there is to it.  I hope that you find it useful.
  115.  
  116. Gayle Davis
  117. GDSOFT
  118.